home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / qfml10.zip / EXAMPLE1.CPP next >
C/C++ Source or Header  |  1995-01-27  |  2KB  |  91 lines

  1. /*********************************************************************
  2. ** QFML DEMO :
  3. **   ALTHOUGH THIS LISTING CAN'T BE MODIFIED, IT SHOWS HOW QFM WORKS.
  4. **   II JUST SHOWS HOW TO USE SOME POKE'S AND PEEK'S.
  5. **   A VERY SIMPLE EXAMPLE OF QFM.
  6. **
  7. ** THIS WAS COMPILED USING A BORLANDC(3.1) PROJECT, TRANSLATED INTO A MAKE
  8. ** WITH BORLAND'S PRJ2MAK AND ADDING /3 TO TLINK LINE IN THE MAKE.
  9. ** (C) RENDER OF ACC TEAM (1995)
  10. *********************************************************************/
  11.  
  12. #include "qfml.h"
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #define dword unsigned long int
  17.  
  18. //============================================================
  19. // Look carefully at this one, this is the IMPORTANT BIT.
  20.  
  21. void
  22. main(void)
  23. {
  24.     dword First_addr;                 // Keeps starting QFM's memory address
  25.     dword MCGA_off;                   // Plane address of video mem.
  26.     dword num_ks;                     // Keeps the amount of K's reserved
  27.  
  28.     // First of all start QFM before leaving textmode
  29.     if (StartPL()) exit(1);
  30.  
  31.     // Then open the whole mem after the first Megabyte.
  32.     if (OpenMem()) {
  33.       LeavePL();           // Leave QFM mode before leaving your code.(ALWAYS)
  34.       exit(1);
  35.     }
  36.  
  37.     // We get the amount of memory available
  38.     num_ks=GiveAmo();
  39.     if (num_ks<1) {        // We need a minimum of 1 k
  40.       CloseMem();          // Close mem. before leavinf QFM. (ALWAYS)
  41.       LeavePL();           // Leave QFM mode before leaving your code.(ALWAYS)
  42.     }
  43.     printf ("Available memory after first Mgb. (Kbytes):%lu\n",num_ks);
  44.  
  45.     // Then we need the starting address of this block in plane
  46.     // memory. Observe it will always be after position 1048576 (1Mb)
  47.     First_addr=GiveSta();
  48.  
  49.  
  50.     // First Poke data and then peek it to check it
  51.     Pokeb(First_addr+10,101);
  52.     printf ("Peekb(%lu)=%d\n",First_addr+10,Peekb(First_addr+10));
  53.  
  54.     Pokew(First_addr+10,0xFFFF);
  55.     printf ("Peekw(%lu)=%u\n",First_addr+10,Peekw(First_addr+10));
  56.  
  57.     Pokedw(First_addr+10,0x00010001);
  58.     printf ("Peekdw(%lu)=%lu\n",First_addr+10,Peekdw(First_addr+10));
  59.  
  60.  
  61.     // Close openned mem. before living
  62.     CloseMem();
  63.  
  64.     // Leave QFM before termination
  65.     LeavePL();
  66. }
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.